package com.villaday.idf.fragment3;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.bumptech.glide.Glide;
import com.bumptech.glide.Priority;
import com.bumptech.glide.request.RequestOptions;
import com.villaday.idf.R;
import com.villaday.idf.base.BaseFragment;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

public class SleepFragment extends BaseFragment {


    @BindView(R.id.img_sleep)
    ImageView imgSleep;
    @BindView(R.id.vw_sleep)
    View vwSleep;
    @BindView(R.id.ll_st)
    RelativeLayout llSt;


    @Override
    protected int getViewResId() {
        return R.layout.recycle_sleep_top;
    }

    public static SleepFragment instance(int position, String url) {
        SleepFragment sleepFragment = new SleepFragment();
        Bundle bundle = new Bundle();
        bundle.putInt("position", position);
        bundle.putString("imgUri", url);
        sleepFragment.setArguments(bundle);
        return sleepFragment;
    }

    @Override
    protected void init(View v) {
        String imgUri = getArguments().getString("imgUri");

        RequestOptions options = new RequestOptions()
                .placeholder(R.drawable.ic_replace)
                .error(R.drawable.ic_replace)
                .priority(Priority.HIGH)
                .skipMemoryCache(true)
                .centerCrop();
        Glide.with(this)
                .asBitmap()
                .load(imgUri)
                .apply(options)
                .into(imgSleep);
    }
}
